package com.biter.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import android.content.Context;
import android.widget.Toast;

public class StringHelper {

	public static boolean isEmpty(String param) {
		if (param == null || param.equals("") || param.equals(" ")
				|| param.equals("null"))
			return true;
		else
			return false;
	}

	public static String isEmpty(String param, String default_value) {
		if (param == null || param.equals("") | param.equals(" ")
				|| param.trim().equals("null"))
			return default_value;
		else
			return param;
	}

	public static boolean isEquals(String param, String param1) {
		if (isEmpty(param)) {
			return false;
		} else if (param.equals(param1)) {
			return true;
		} else {
			return false;
		}
	}

	public static void sendShortMsg(Context c, String text) {
		Toast.makeText(c, text, Toast.LENGTH_SHORT).show();
	}

	public static void sendLongMsg(Context c,String text) {
		Toast.makeText(c, text, Toast.LENGTH_LONG).show();
	}
	
	public static boolean checkEmail(String line){
	    Pattern p = Pattern.compile("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");
	    Matcher m = p.matcher(line);
	    return m.find();
	}
	
	public static boolean checkUserFormat(String user){
	    Pattern p = Pattern.compile("[0-9a-zA-Z]+");
	    Matcher m = p.matcher(user);
	    return m.find();	
	}
}
